package nl.science.uva.pico.operator;

import nl.science.uva.pico.ProgramCounter;
import nl.science.uva.pico.Stack;
import nl.uva.science.pico.stacklanguage.types.LabelInstrList;

/** 
 * Goto jumps to the label indicated (label is Integer) 
 * 
 * @author Ivo van Dongen, Karel Pieterson
 * @version 1.0  
 */
public class Goto extends Operator {

	public Goto(Stack stack, ProgramCounter programCounter,LabelInstrList programListing) {
		super(stack, programCounter, programListing);
	}

    /** 
     * After execution of this instruction, the execution of the program is continued at 
     * statement with label x.
     *  
     */
	@Override
	public void perform() {
		gotoLabel(getStack().pop().getIntegerValue());
	}

}
